Skip to content

fix: warn on deprecated Gemini model alias#6011

Open
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/deprecated-model-alias-message
Open

fix: warn on deprecated Gemini model alias#6011
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/deprecated-model-alias-message

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • warn when LLMRegistry.new_llm() sees the deprecated gemini-flash-latest alias
  • keep behavior unchanged: the configured model string is still passed through as-is
  • add regression coverage for both plain and gemini:-prefixed alias usage

Fixes #6010.

To verify

  • PYTHONPATH=src python -m pytest tests\unittests\models\test_models.py -q
  • python -m pyink --check src\google\adk\models\registry.py tests\unittests\models\test_models.py
  • git diff --check

@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Response from ADK Triaging Agent

Hello @he-yufeng, thank you for creating this PR!

We noticed a couple of items from our contribution guidelines that could be added to help the review process:

  1. Summary of Passed Pytest Results: Please include the console output or a summary showing that the tests passed successfully when running pytest.
  2. Logs or Screenshots: For bug fixes or features, please provide logs or a screenshot of the fix in action (for example, showing the deprecation warning being logged when the deprecated alias is used).

This additional context will help the reviewers understand and verify the fix more efficiently. Thank you!

@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

🔍 ADK Pull Request Analysis: PR #6011

Title: fix: warn on deprecated Gemini model alias
Author: @he-yufeng
Status: open
Impact: 35 additions, 0 deletions across 2 files

Executive Summary

  1. Core Objective: Warn users early when LLMRegistry.new_llm() is called with a deprecated Gemini alias (specifically 'gemini-flash-latest'), advising them to transition to versioned models (like 'gemini-2.5-flash') before experiencing runtime crashes.
  2. Justification & Value: Justified Fix - Startup validation warnings prevent downstream 404 NOT_FOUND client crashes during agent execution, heavily improving debugging/logging clarity on platform deployments like Cloud Run.
  3. Alignment with Principles: Pass - Features clean, private encapsulation boundaries, lazy key-evaluation logs, strict typing, and comprehensive behavior-focused parametrized unit tests.
  4. Recommendation: Approve (Zero changes or pushback needed).
Detailed Findings & Analysis

1. Objectives & Impact ("What does it do?")

  • Context & Background: Resolves Issue #6010. When older apps or tutorials make use of the gemini-flash-latest alias, the underlying backend (which maps it to gemini-2.0-flash) has been deprecated by Google. This surfaces as a silent 404 NOT_FOUND error far down the agent invocation chain, confounding developers because the error message mentions gemini-2.0-flash which they did not explicitly configure.
  • Implementation Mechanism:
    • Defines the map _deprecated_model_aliases mapping 'gemini-flash-latest' to 'gemini-2.5-flash'.
    • Implements the private helper method _warn_if_deprecated_alias that checks if the resolved model matches any entry in _deprecated_model_aliases and emits a warning on a match.
    • Plugs _warn_if_deprecated_alias into LLMRegistry.new_llm() immediately after model-parsing.
  • Affected Surface: No public namespace changes or API stability concerns; purely logs warnings.

2. Justification & Value ("Is it a valid and useful change?")

  • Workspace Verification:
    • Investigated registry.py in the active workspace.
    • Confirmed that baseline lacks explicit alias validation or deprecation warning checks when resolving or instantiating aliases like gemini-flash-latest.
  • Value Assessment: Highly valuable. Early reporting at creation/configuration time greatly simplifies troubleshooting configuration bugs.
  • Alternative Approaches:
    • Silently upgrading the string mapping internally: Decided against because versioned Gemini engines might exhibit minor quality differences; forcing auto-replacement can cause unwanted behavioral shifts. Emitting a warning leaves the control safely with the developer.
  • Scope & Depth: Systematic Fix / Root Cause - Resolves the systemic feedback problem for deprecated aliases by establishing an extensible _deprecated_model_aliases dictionary pattern for simple future updates.

3. Principle & Style Alignment Checklist ("Does it follow rules?")

  • Public API & Visibility Boundaries:
    • Status: Pass
    • Analysis: Keeps both _deprecated_model_aliases and _warn_if_deprecated_alias private to registry.py ensuring no public-facing changes to existing interfaces.
  • Code Quality, Typing & Conventions:
    • Status: Pass
    • Analysis: Consistently imports futurized annotations via from __future__ import annotations and type-hints parameters correctly. Strictly relies on lazy-evaluated logging templates (uses % format specifiers rather than eager f-strings in logger.warning).
  • Robustness & Edge Cases:
    • Status: Pass
    • Analysis: Properly processes plain aliases as well as those containing prefixed tags (like gemini:gemini-flash-latest) through the parser prior to execution.
  • Test Integrity & Quality:
    • Status: Pass
    • Analysis: Introduces test_new_llm_warns_for_deprecated_model_alias which parameterizes test cases, intercepts log entries with caplog, verifies type correctness to Gemini, and checks message contents under the Arrange-Act-Assert format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecated model alias (gemini-flash-latest) causes confusing 404 NOT_FOUND with no actionable guidance

2 participants